<?php

namespace App\Providers;

use App\Observers\BaseSettingObserver;
use App\Observers\CisAdminObserver;
use App\Observers\CisAdminRoleObserver;
use App\Observers\CisUserObserver;
use App\Observers\CmsArticleObserver;
use App\Observers\FinaIntegralRegRecordObserver;
use App\Observers\GoodsInfoObserver;
use App\Observers\OrderInfoObserver;
use App\System\Base\Model\BaseSetting;
use App\System\Cis\Model\CisAdmin;
use App\System\Cis\Model\CisAdminRole;
use App\System\Cis\Model\CisUser;
use App\System\Cms\Model\CmsArticle;
use App\System\Fina\Model\FinaIntegralRegRecord;
use App\System\Goods\Model\GoodsInfo;
use App\System\Order\Model\OrderInfo;
use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * The event listener mappings for the application.
     *
     * @var array
     */
    protected $listen = [
        'App\Events\Event'                         => [
            'App\Listeners\EventListener',
        ],
        // 新增SqlListener监听QueryExecuted
        'Illuminate\Database\Events\QueryExecuted' => [
            'App\Listeners\SqlListener',
        ],
    ];

    /**
     * Register any events for your application.
     *
     * @return void
     */
    public function boot()
    {
        parent::boot();
        /**
         * 注册所有模型观察者
         */
        //用户表---观察者
        CisUser::observe(CisUserObserver::class);
        //设置表---观察者
        BaseSetting::observe(BaseSettingObserver::class);
        //文章表---观察者
        CmsArticle::observe(CmsArticleObserver::class);
        //管理员表---观察者
        CisAdmin::observe(CisAdminObserver::class);
        //管理员角色表---观察者
        CisAdminRole::observe(CisAdminRoleObserver::class);
        //商品表---观察者
        GoodsInfo::observe(GoodsInfoObserver::class);
        //订单表---观察者
        OrderInfo::observe(OrderInfoObserver::class);
        //财务表---观察者
        FinaIntegralRegRecord::observe(FinaIntegralRegRecordObserver::class);
        //
    }
}
